<?php
// Send HTTP headers, cookies, and/or other stuff before we send any content to the browser
function template_onLoad($db) {
	try {
		$data = $db->fetchRow('SELECT COUNT(*) FROM tmp');
	} catch (Zend_Exception $e) {
		$stmt = $db->query('CREATE TABLE IF NOT EXISTS `tmp` (`field1` text default NULL, `field2` datetime default NULL)');
	}
	$GLOBALS['logger']->log('I just did stuff' , Zend_Log::INFO); // see Zend_Log for more info
}

// Called in between the <head> tags
// Insert page specific JavaScript, CSS, etc here
function template_head($db, &$headers, $translate) {
	$headers->headTitle('title');
	$headers->headMeta()->setName('keywords', 'one,two,three');
	$headers->headScript()->appendFile('script.js');
}

// GCMS calls main when it's rendering the page content
function template_main($db, &$view, $translate) {
	global $config;
	$view->display('main.tpl');
}

// Called when you submit an article or news post before it goes into the database
function template_onSubmit(&$title, &$content, &$tags) {
	$title .= "!";
}

// Add an admin menu item
// Returns an array with the first value as the title and menu options after that
function template_adminMenu($translate) {
	$stack = array();
	$stack[] = "Template Config";
	$stack['action=item1'] = "Template Menu Item 1";
	$stack['action=item2'] = "Template Menu Item 2";
	return $stack;
}

// If you want to format your output for a printer you can do so here
function template_print($db, &$view, $translate) {
	$view->getEngine()->load_filter('output', 'geshi');
	$view->display('file:../../../modules/template/print.tpl');
}

// Add any "Pagelets" that you might need.
// You can then add these to your page by calling {insert name="template" arg1="optional arg"}
function insert_template($args) {

}
?>